:root {
  --sidebar-bg: #252526;
  --sidebar-text: #cccccc;
  --editor-bg: #1e1e1e;
  --main-bg: #ffffff;
  --text-color: #333333;
  --border-color: #333333;
  --menu-bg: #2c2c2d;
  --menu-hover-bg: #094771;
  --primary-color: #007acc;
  --primary-hover: #009cff;
  --secondary-button-bg: #3c3c3c;
  --secondary-button-hover-bg: #4f4f4f;
  --active-bg: rgba(153, 153, 153, 0.2);
  --drag-over-bg: rgba(0, 122, 204, 0.3);
  --line-number-bg: #f7f7f7;
  --line-number-text: #858585;
  --drag-indicator: 2px dashed var(--primary-color);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  background-color: var(--editor-bg);
}

.main-container {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 280px;
  min-width: 200px;
  max-width: 50%;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  height: 100%;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sidebar-header {
  padding: 12px 15px;
  font-weight: 600;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-actions {
  display: none;
  gap: 8px;
}

.sidebar-actions button {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  transition: background-color 0.2s;
}

.sidebar-actions button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
  padding: 10px;
  overflow-y: auto;
  flex-grow: 1;
  position: relative;
}

.resizer {
  width: 4px;
  background: var(--border-color);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.resizer:hover {
  background-color: var(--primary-color);
}

.open-buttons-container {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 15px;
}

.action-button,
.action-button-secondary {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.action-button {
  background-color: var(--primary-color);
  color: white;
}

.action-button:hover {
  background-color: var(--primary-hover);
}

.action-button-secondary {
  background-color: var(--secondary-button-bg);
  color: var(--sidebar-text);
}

.action-button-secondary:hover {
  background-color: var(--secondary-button-hover-bg);
}

.action-button-save {
  padding: 6px 16px;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid var(--primary-color);
  background-color: var(--primary-color);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.action-button-save:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.action-button-save:disabled {
  background-color: #555;
  color: #888;
  border-color: #555;
  cursor: not-allowed;
}

.file-tree {
  padding-bottom: 50px;
  min-height: calc(100% - 50px);
  position: relative;
}

.file-tree:empty {
  padding-bottom: 0;
  min-height: 0;
}

.file-tree.drag-over {
  outline: var(--drag-indicator);
  outline-offset: -2px;
}

.tree-item {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-bottom: 3px;
}

.tree-item-content {
  display: flex;
  align-items: center;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.1s;
}

.tree-item.active > .tree-item-content {
  background-color: var(--active-bg);
}

.tree-item.drag-over > .tree-item-content {
  background-color: var(--drag-over-bg);
  box-shadow: 0 0 0 2px var(--primary-color);
}

.tree-item.dragging {
  opacity: 0.5;
}

.tree-item-icon {
  width: 18px;
  text-align: center;
  margin-right: 5px;
  flex-shrink: 0;
  pointer-events: none;
}

.tree-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
  pointer-events: none;
  font-size: 14px;
}

.rename-input {
  position: absolute;
  top: 3px;
  left: 23px;
  width: calc(100% - 30px);
  height: 24px;
  padding: 2px 4px;
  border: 1px solid var(--primary-color);
  background: #3c3c3c;
  color: white;
  outline: none;
  border-radius: 3px;
  font-size: 14px;
}

.folder-children {
  padding-left: 18px;
  margin-top: 2px;
}

.item-actions {
  display: none;
  margin-left: auto;
  padding-left: 8px;
  gap: 4px;
}

.tree-item-content:hover .item-actions {
  display: flex;
}

.item-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-text);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 14px;
  transition: background-color 0.1s;
}

.item-actions button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.new-item-input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--primary-color);
  border-radius: 3px;
  outline: none;
  margin: 4px 0;
  background-color: #3c3c3c;
  color: white;
  font-size: 13px;
}

.main-content {
  flex-grow: 1;
  display: flex;
  min-width: 0;
  background-color: var(--main-bg);
}

.editor-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.editor-area {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}

.editor-wrapper {
  display: flex;
  height: 100%;
  width: 100%;
}

.line-numbers {
  width: 55px;
  padding: 15px 10px 15px 0;
  text-align: right;
  color: var(--line-number-text);
  background-color: var(--line-number-bg);
  overflow: hidden;
  line-height: 1.7;
  font-size: 14px;
  user-select: none;
}

#editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 15px;
  line-height: 1.7;
  resize: none;
  background-color: var(--main-bg);
  font-size: 14px;
  tab-size: 2;
}

.placeholder {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: #888;
  text-align: center;
  padding: 20px;
  flex-direction: column;
}

.welcome-content {
  max-width: 500px;
  text-align: center;
}

.welcome-content h2 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #555;
}

.welcome-content p {
  margin-bottom: 10px;
  font-size: 16px;
  line-height: 1.6;
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  border-top: 1px solid #e1e4e8;
  background-color: #f6f8fa;
  flex-shrink: 0;
}

#file-path-display {
  font-size: 12px;
  color: #586069;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.context-menu {
  display: none;
  position: absolute;
  z-index: 1000;
  background-color: var(--menu-bg);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 5px 0;
  min-width: 120px;
}

.context-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.context-menu li {
  padding: 8px 15px;
  cursor: pointer;
  color: var(--sidebar-text);
  white-space: nowrap;
  font-size: 13px;
  transition: background-color 0.1s;
}

.context-menu li:hover {
  background-color: var(--menu-hover-bg);
}

.error-message {
  color: #ff4444;
  background-color: #ffeeee;
  padding: 8px 12px;
  border-radius: 4px;
  margin: 5px 0;
  font-size: 14px;
}

.drag-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary-color);
  z-index: 100;
  display: none;
}

.drag-indicator.visible {
  display: block;
}

@media (max-width: 768px) {
  .sidebar {
    width: 200px;
  }

  .line-numbers {
    width: 40px;
    padding-right: 5px;
    font-size: 12px;
  }

  #editor {
    padding: 10px;
    font-size: 13px;
  }
}
